﻿/*----------------------------------------------------------------
// Copyright (C) 2014 苏州麦迪斯顿医疗科技股份有限公司
// 文件名：UnityServiceBehaviorExtension.cs
// 文件功能描述：UnityServiceBehaviorExtension
// 创建标识：顾伟伟-2014-04-03
----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel.Configuration;
using System.Configuration;

namespace CPOE.Framework.Injection
{
    /// <summary>
    /// 通过配制文件,扩展WCF服务行为和终结点行为，实现服务实例的依赖注入和策略注入的配制元素
    /// </summary>
    public class UnityServiceBehaviorExtension : BehaviorExtensionElement
    {
        protected override object CreateBehavior()
        {
            return new UnityServiceBehaviorAttribute(this.ContainerName);
        }
        public override Type BehaviorType
        {
            get
            {
                return typeof(UnityServiceBehaviorAttribute);
            }
        }
        [ConfigurationProperty("containerName", IsRequired = false, DefaultValue="defaultContainer")]
        public string ContainerName
        {
            get
            {
                return this["containerName"] as string;
            }
            set
            {
                this["containerName"] = value;
            }
        }
    }
}
